package leetcode.秋招.字节跳动.字节研发在线编程;

import org.junit.Test;

/**
 * @author ：zsy
 * @date ：Created 2021/7/25 17:44
 * @description：https://www.nowcoder.com/practice/253d2c59ec3e4bc68da16833f79a38e4?tpId=190&&tqId=35178&rp=1&ru=/activity/oj&qru=/ta/job-code-high-rd/question-ranking
 */
public class NC3链表中环的入口结点 {
    @Test
    public void test() {
        Solution solution = new Solution();
    }


    public class ListNode {
        int val;
        ListNode next = null;

        ListNode(int val) {
            this.val = val;
        }
    }

    public class Solution {

        public ListNode EntryNodeOfLoop(ListNode pHead) {
            if (pHead == null || pHead.next == null || pHead.next.next == null) return null;
            ListNode slow = pHead;
            ListNode fast = pHead.next.next;
            while (slow != null && fast.next != null) {
                if (slow == fast) return slow;
                //slow =
            }
            return null;
        }
    }
}
